<template>
 <div> 
     <!-- <el-button
                size="mini"
                type="success"
                @click="showuserbook()"
                >借书详细</el-button
              > -->
   <el-table :data="tabledatas">
          <el-table-column prop="bookname" label="图书">
            <!-- <template slot-scope="scope">
                    <el-input placeholder="请输入图书" v-show="show" v-model="scope.row.bookname"></el-input>
                    <span v-show="!show">{{scope.row.bookname}}</span>
                </template> -->
          </el-table-column>
          <el-table-column prop="author" label="作者">
            <!-- <template slot-scope="scope">
                    <el-input placeholder="请输入作者" v-show="show" v-model="scope.row.author"></el-input>
                    <span v-show="!show">{{scope.row.author}}</span>
                </template> -->
          </el-table-column>
          <el-table-column prop="publisher" label="出版社">
            <!-- <template slot-scope="scope">
                    <el-input placeholder="请输入出版社" v-show="show" v-model="scope.row.publisher"></el-input>
                    <span v-show="!show">{{scope.row.publisher}}</span>
                </template> -->
          </el-table-column>
          <!-- <el-table-column v-show="usershow" prop="details" label="简介">
            <template slot-scope="scope">
                    <el-input placeholder="请输入简介" v-show="show" v-model="scope.row.details"></el-input>
                    <span v-show="!show">{{scope.row.details}}</span>
                </template>
          </el-table-column> -->
          <!-- <el-table-column v-show="usershow" prop="img" label="封面">
            <template slot-scope="scope">
                    <el-input placeholder="请输入简介" v-show="show" v-model="scope.row.img"></el-input>
                    <span v-show="!show">{{scope.row.img}}</span>
                </template>
          </el-table-column> --> -->
          <el-table-column label="操作">
            <!-- slot-scope插槽 -->
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="danger"
                @click="Return(scope.$index,scope.row)"
                >还书
                </el-button>
            </template>
          </el-table-column>
        </el-table>
 </div> 
</template>
<script>
export default ({
    data() {
        return {
        tabledatas: [],
        userbooks: {
        username: "",
        bookname: "",
        author: "",
        publisher: "",
         registerForm: {
        bookname: "",
        author: "",
        publisher: "",
        details: "",
        img: ""
      },
      },
        }
    },
     created() {
      this.showuserbook();
    },
    methods:{
        showuserbook() {
      //  var username = sessionStorage.getItem("username");
      //  this.username=username;
      //  console.log(row);
      // console.log('借书');
      this.$axios
        .get("http://127.0.0.1:7001/api/userbook/finduserbook")
        
        .then((res) => {
          this.tabledatas = res.data;
          // console.log(res)
        });
    },
    Return(index,row) {
        // this.$axios
        this.$axios
        .post("http://127.0.0.1:7001/api/book",row)
        this.$message.success({ message: "还书成功", center: true });
        this.$axios.delete("http://127.0.0.1:7001/api/userbook/delete?_id=" + row._id).then( res => {
            this.showuserbook()
          })
        
    
        
    }
    }
})
</script>
<style scoped>

</style>
